const _function = require("../../utils/functionData.js")
Page({
  data: {
    isRefreshing: false,
    isLoading: false,
    hasMore: true,
    page: 1,
    lectureList: [
    //   {
    //   id: 1,
    //   name: "人工智能前沿技术解析",
    //   startTime: "2023-10-10 14:00",
    //   participants: 156
    // }
  ],
    _UrlGet_: wx.getStorageSync('img_url')
  },
  onLoad() {
    this.getVideoList()
  },
  // 获取视频列表
  getVideoList(e) {
    console.log('选择时间', getApp().globalData.userInfo);
    const param = {
        uploadId:getApp().globalData.userInfo.userId
    }
    _function.getVideoList(param, this.getVideoListBack, this)
  },
  getVideoListBack(res) {
    let dataAll = res.data
    if (dataAll.code == 200) {
      console.log('视频列表', dataAll);
      this.setData({
        lectureList: dataAll.rows
      })
      wx.showToast({
        title: dataAll.msg,
        icon: 'none', // 不显示图标
        duration: 1500, // 提示的延迟时间，单位毫秒，默认为 1500
        mask: true, // 是否显示透明蒙层，防止触摸穿透，默认为 `false`
        success: () => {
          // console.log('登录失败提示已显示');
        }
      });
    }
  },
  onPullDownRefresh() {
    this.setData({ isRefreshing: true });
    setTimeout(() => {
      this.setData({
        lectureList: [...newData],
        isRefreshing: false,
        page: 1
      });
      wx.stopPullDownRefresh();
    }, 1500);
  },

  loadMore() {
    if (!this.data.hasMore || this.data.isLoading) return;

    this.setData({ isLoading: true });
    setTimeout(() => {
      this.setData({
        lectureList: [...this.data.lectureList, ...newData],
        page: this.data.page + 1,
        isLoading: false,
        hasMore: this.data.page < 3
      });
    }, 1000);
  }
});